﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Web;

namespace ERPU8WebApi.App_Start
{
    public class U8LoginConfig
    {
        public U8Login.clsLogin u8Login=new U8Login.clsLogin();
        private static U8LoginConfig _instance = null;
        private U8LoginConfig() { }
        public static U8LoginConfig CreateInstance()
        {
            if (_instance == null)
            {
                _instance = new U8LoginConfig();
            }
            return _instance;
        }

        public string U8Login()
        {
            //u8Login = new U8Login.clsLogin();
            String sSubId = System.Configuration.ConfigurationManager.AppSettings["LoginsSubId"].ToString();
            String sAccID = System.Configuration.ConfigurationManager.AppSettings["LoginsAccID"].ToString();
            String sYear = System.Configuration.ConfigurationManager.AppSettings["LoginsAccYear"].ToString();
            String sUserID = System.Configuration.ConfigurationManager.AppSettings["LoginsUserID"].ToString();
            String sPassword = System.Configuration.ConfigurationManager.AppSettings["LoginsPassword"].ToString();
            String sDate = System.Configuration.ConfigurationManager.AppSettings["LoginSDate"].ToString() == ""
                ? DateTime.Now.ToString("yyyy-MM-dd")
                : System.Configuration.ConfigurationManager.AppSettings["LoginSDate"].ToString();
            String sServer = System.Configuration.ConfigurationManager.AppSettings["LoginsServer"].ToString();
            String sSerial = System.Configuration.ConfigurationManager.AppSettings["LoginsSerial"].ToString();
            if (!u8Login.Login(ref sSubId, ref sAccID, ref sYear, ref sUserID, ref sPassword, ref sDate, ref sServer, ref sSerial))
            {
                string s1 = u8Login.ShareString.ToString();
                Marshal.FinalReleaseComObject(u8Login);
                return s1;
            }
            return "登录成功";
        }
    }
}